using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiSugar.Configuration;
using EPiSugar.EntityAdapter;

namespace EPiSugar
{
    /// <summary>
    /// Static gateway to services provided by EPiSugar Utilities.
    /// </summary>
    public static class Current
    {
        public static EntityModel Model { get; set; }
        public static IPageSource PageSource { get; set;}

        public static void Initialize(EPiSugarSection config, PageTypeCollection pageTypes, IPageSource pageSource)
        {
            PageSource = pageSource;
            if (config != null && pageTypes != null)
            {
                Model = new ModelBuilder(config.TypeMappings, pageTypes).Build();
            }
        }
        public static void Dispose()
        {
            PageSource = null;
            Model = null;
        }
    }
}
